package common;

import java.util.Hashtable;
import java.util.Iterator;

/**
 *A storage class to hold the point value associated with a category
 */
public class CatAndPoints implements Iterable<Integer>
{
	Hashtable<Integer, Category> categories = new Hashtable<Integer, Category>();

	public void add(int cat, int points, String descr)
	{
		categories.put(cat, new Category(points, descr));
	}

	public String getDescription(int cat)
	{
		return categories.get(cat).description;
	}

	public int getPoints(int cat)
	{
		return categories.get(cat).points;
	}

	private class Category
	{
		String description;
		int points;

		/**
		 * Constructor to create a new category
		 * 
		 * @param points
		 *            Point value of the category
		 * @param description
		 *            A description of the category
		 */
		public Category(int points, String description)
		{
			this.points = points;
			this.description = description;
		}
	}

	/**
	 * Iterates over the categories found in the database.
	 * 
	 * @return Iterator<Integer> An iterator that returns category numbers.
	 */
	public Iterator<Integer> iterator()
	{
		return categories.keySet().iterator();
	}
}
